﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<script type="text/javascript">
    function doapplyadd() {
        var sqr_id = $("#applyadd #sqr_id").val();
        var apply_stime = $("#applyadd #apply_stime").val();
        var apply_etime = $("#applyadd #apply_etime").val();
        var car_id = $("#applyadd #car_id").val();
        if (apply_stime == undefined || apply_stime == "") {
            alert("请选择开始时间");
            return;
        }
        if (apply_etime == undefined || apply_etime == "") {
            alert("请选择结束时间");
            return;
        }
        if (car_id == undefined || car_id == "") {
            alert("请选择申请车辆");
            return;
        }
        var shour = apply_stime.split(" ")[1].split(":")[0];
        var ehour = apply_etime.split(" ")[1].split(":")[0];

        if (shour < 8 || shour > 18 || ehour < 8 || ehour > 18) {
            alert("开始时间和结束时间必须是8-18点之间");
            return;
        }
        var apply_person = $("#apply_person").val();
        $.ajax({
            type: "POST",
            url: "/Car/DoApplyAdd",
            data: { "apply_stime": apply_stime, "apply_etime": apply_etime, "apply_person": apply_person, "sqr_id": sqr_id, "car_id": car_id },
            success: function(restag) {
                if (!restag.res) {
                    alert(restag.msg);
                }
                else {
                    alert("操作成功");
                    $.fn.deltab('apply-1');
                }
            }
        })
    }
</script>

<div id="applyadd">
    <div>
        <input type="button" value="确定" onclick="doapplyadd()" />
        <%=Html.Hidden("sqr_id", ViewData["sqr_id"])%>
    </div>
    <div style="padding-top: 20px;">
        <div style="margin: 5px;">
            开始时间:<input id="apply_stime" class="Wdate" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:00:00',readOnly:true,maxDate:'#F{$dp.$D(\'apply_etime\',{d:0});}'})" />
            结束时间:<input id="apply_etime" class="Wdate" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:00:00',readOnly:true,minDate:'#F{$dp.$D(\'apply_stime\',{d:0});}'})" />
        </div>
        <div style="margin: 5px;">
            车辆名称:<%=Html.DropDownList("car_id", ViewData["list_car"] as List<SelectListItem>, "---------请选择---------", new { @style = "width:202px; margin-left:8px; padding:0px;border-radius:0px 0px 0px 0px;border:solid 1px #6C92AD;" })%>
        </div>
        <div style="margin: 5px;">
            事由:<textarea id="apply_person" cols="10" rows="5" style="border: 1px solid #6C92AD;
                width: 614px;"></textarea>
        </div>
    </div>
</div>
